package b649a01.poperators;

import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import b649a01.runners.sim_p;

/***
 * 
 * Basic class for calculators.
 * 
 * @author Chao Sun
 * @version 1.0
 */
public abstract class calculator {
	protected int pipelineIndex;
	protected String operator;
	protected sim_p simulator;
	protected int insNum;
	protected int cycleNum;
	protected boolean finishFlag;
	protected boolean aliveFlag;
	protected int R[] = null;
	protected double F[] = null;
	protected Vector<String> readRegs;
	protected Vector<String> writeRegs;
	protected Vector<Integer> readMemOffs;
	protected Vector<Integer> writeMemOffs;
	protected String busyComUnit;
	protected String target;
	protected String source1;
	protected String source2;
	protected int tIndex;
	protected int s1Index;
	protected int s2Index;
	protected Properties readRegProperty;
	protected Properties writeRegProperty;
	protected Properties readMemProperty;
	protected Properties writeMemProperty;
	protected Properties comUnitProperty;

	/**
	 * Constructor.
	 * 
	 * @param sim
	 *          the simulator associated to this calculator
	 * @param i
	 *          the index of instruction related to this operation
	 * @param pipeN
	 * 					the pipeline serial number
	 * @param op
	 * 					the operation name
	 */
	public calculator(sim_p sim, int i, int pipeN, String op) {
		this.pipelineIndex = pipeN;
		this.simulator = sim;
		this.insNum = i;
		this.operator = op;
		this.finishFlag = false;
		this.aliveFlag = true;
		readRegs = new Vector<String>();
		writeRegs = new Vector<String>();
		readMemOffs = new Vector<Integer>();
		writeMemOffs = new Vector<Integer>();
		busyComUnit = null;
		target = source1 = source2 = null;
		readRegProperty = new Properties();
		writeRegProperty = new Properties();
		readMemProperty = new Properties();
		writeMemProperty = new Properties();
		comUnitProperty = new Properties();
	}

	public int getpipelineIndex() {
		return pipelineIndex;
	}
	
	public String getOperator() {
		return operator;
	}

	public int getInsNum() {
		return insNum;
	}

	public int getcycleNum() {
		return cycleNum;
	}

	public Vector<String> getreadRegs() {
		return readRegs;
	}

	public Vector<String> getwriteRegs() {
		return writeRegs;
	}

	public Vector<Integer> getreadMemOffs() {
		return readMemOffs;
	}

	public Vector<Integer> getwriteMemOffs() {
		return writeMemOffs;
	}

	public String getbusyComUnit() {
		return busyComUnit;
	}

	public Properties getreadRegProperty() {
		return readRegProperty;
	}

	public Properties getwriteRegProperty() {
		return writeRegProperty;
	}

	public Properties getreadMemProperty() {
		return readMemProperty;
	}

	public Properties getwriteMemProperty() {
		return writeMemProperty;
	}

	public Properties getcomUnitProperty() {
		return comUnitProperty;
	}

	public boolean getaliveFlag() {
		return aliveFlag;
	}

	public void fetchRegs(StringTokenizer opTokenizer) {
	}

	public void assignRegs() {
	}

	public void execute() {
	}

	public void memory() {
	}

	public void writeBack() {
	}

}